package logic

import (
	"context"
	"hosp/models"

	"hosp/hosprpc/hosprpc"
	"hosp/hosprpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type PatientShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPatientShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PatientShowLogic {
	return &PatientShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 详情
func (l *PatientShowLogic) PatientShow(in *hosprpc.PatientShowRequest) (*hosprpc.PatientShowResponse, error) {
	// todo: add your logic here and delete this line

	var patient models.Patient

	err := patient.PatientShowById(models.DB, in.PatientId)
	if err != nil {
		return nil, err
	}

	return &hosprpc.PatientShowResponse{
		Name:       patient.Name,
		IdCard:     patient.IdCard,
		NickName:   patient.NickName,
		Address:    patient.Address,
		CardNumber: patient.CardNumber,
		IdNumber:   patient.IdNumber,
		Tel:        patient.Tel,
		PatientId:  int64(patient.ID),
	}, nil
}
